<template>
  <div class="settings">
    <van-nav-bar safe-area-inset-top placeholder :title="$t('ManufactorySetting')" left-arrow fixed @click-left="onClickLeft" />
    <van-pull-refresh v-model="isLoading" :pulling-text="$t('PullingText')" :loosing-text="$t('PullingText')" :success-text="$t('refreshSuccee')" @refresh="onRefresh">
      <van-collapse class="marginTop15" v-model="activeNames">
        <van-collapse-item title="DIO Function" name="2" style="display:none;">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.DIOFunctionValue" :reg="113"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item title="COM Port Select" name="3">
          <languagePTVue :columns="COMPortSelectArr" :setValue="LocalArr.COMPortSelectValue" :reg="114"></languagePTVue>
        </van-collapse-item>
      </van-collapse>
    </van-pull-refresh>
  </div>
</template>

<script>
import languagePTVue from '../../../components/Language/BDLanguagePT'

export default {
  components:{
    languagePTVue
  },
  data(){
    return {
      isLoading:false,
      activeNames:[],
      toggleArr:[this.$t('Disable'),this.$t('Enable')],
      COMPortSelectArr:['Modbus','ExternalLCD'],
      LocalArr:{
        DIOFunctionValue:'',
        COMPortSelectValue:''
      }
    }
  },
  methods: {
    onClickLeft(){
      this.$router.push({path:'/bdx1hybridg4setlist'});
    },
    async getData(){
      this.comm.loadingShow();
      let datas=await this.SETAPI.LocalIn({'optType':'ReadSetData','pwd':sessionStorage.getItem('bdPwd')});
      if(datas!=null||datas!=undefined){
        let dataArr = datas;
        this.LocalArr.DIOFunctionValue=dataArr[112];
        this.LocalArr.COMPortSelectValue=dataArr[113];
      }else{
        this.comm.tipsShow('InvNoResponse');
      }
    },
    onRefresh(){
      this.isLoading = false;
      for(let i in this.LocalArr){
        this.LocalArr[i]='';
      }
      this.getData();
    }
  },
  mounted(){
    setTimeout(()=>{
      this.getData();
    },1000);
  }
}
</script>

<style scoped lang="less">

</style>
